#include "wparser.h"
extern "C" {
typedef void* yyscan_t;
#include "lexer.h"
#include "parser.h"
}

bool wparser::parse(const char *text) {

    
    YY_BUFFER_STATE state;

    yyscan_t scanner;
    yylex_init(&scanner);

    if (!(state = yy_scan_bytes(text, strcspn(text, "\n"), scanner))) {
        return false;
    }

    ParseContext ret;

    int re;
    if (yyparse( scanner,&re) == 0) {
        printf("= %d\n", re);
    }

    yy_delete_buffer(state, scanner);
    yylex_destroy(scanner);


    return true;
}
